<template>
  <el-container class="admin-layout">
    <el-header>
      <h2>平台管理系统</h2>
      <div class="user-info">
        <span>欢迎，管理员</span>
        <el-button type="text" icon="el-icon-switch-button" @click="logout" class="logout-btn">退出</el-button>
      </div>
    </el-header>
    <el-container>
      <el-aside width="200px">
        <el-menu router default-active="$route.path">
          <el-menu-item index="/admin/home">
            <i class="el-icon-s-home"></i>
            <span>首页</span>
          </el-menu-item>
          <el-submenu index="merchant">
            <template slot="title">
              <i class="el-icon-s-shop"></i>
              <span>商家管理</span>
            </template>
            <el-menu-item index="/admin/merchant/list">商家列表</el-menu-item>
            <el-menu-item index="/admin/merchant/audit">入驻审核</el-menu-item>
          </el-submenu>
          <el-submenu index="rider">
            <template slot="title">
              <i class="el-icon-s-promotion"></i>
              <span>骑手管理</span>
            </template>
            <el-menu-item index="/admin/rider/list">骑手列表</el-menu-item>
            <el-menu-item index="/admin/rider/audit">入驻审核</el-menu-item>
            <el-menu-item index="/admin/dispatch/config">调度配置</el-menu-item>
          </el-submenu>
          <el-submenu index="order">
            <template slot="title">
              <i class="el-icon-s-order"></i>
              <span>订单管理</span>
            </template>
            <el-menu-item index="/admin/order/monitor">订单监控</el-menu-item>
            <el-menu-item index="/admin/order/statistics">订单统计</el-menu-item>
          </el-submenu>
          <el-menu-item index="/admin/category">
            <i class="el-icon-menu"></i>
            <span>商品分类</span>
          </el-menu-item>
          <el-menu-item index="/admin/report">
            <i class="el-icon-s-data"></i>
            <span>报表管理</span>
          </el-menu-item>
        </el-menu>
      </el-aside>
      <el-main>
        <router-view></router-view>
      </el-main>
    </el-container>
  </el-container>
</template>

<script>
export default {
  name: 'AdminLayout',
  methods: {
    logout() {
      localStorage.removeItem('token');
      localStorage.removeItem('userInfo');
      this.$router.push('/login');
    }
  }
}
</script>

<style scoped>
.admin-layout {
  height: 100vh;
}
.el-header {
  background-color: #409EFF;
  color: white;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.el-aside {
  background-color: #f2f2f2;
}
.user-info {
  display: flex;
  align-items: center;
}
.logout-btn {
  color: white;
  margin-left: 15px;
}
</style> 